package com.itheima.interceptor;

import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Description:
 * @Version: V1.0
 */
@Component
@ControllerAdvice//加载成异常处理类
public class AnnoException {
    @ResponseBody
    @ExceptionHandler(NullPointerException.class)
    public String doNullExpection(Exception e){
        return "空指针异常";
    }

    @ResponseBody
    @ExceptionHandler(ArithmeticException.class)
    public String doAirthmenticExpection(Exception e){
        return "Arithmetic";
    }
    @ResponseBody
    @ExceptionHandler
    public String doAllExpection(Exception e){
        return "其他";
    }
}
